{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Monte Carlo Simulation with Python\n",
    "\n",
    "Notebook to accompany article on [Practical Business Python](https://pbpython.com/monte-carlo.html)\n",
    "\n",
    "Update to use numpy for faster loops based on comments [here](https://www.reddit.com/r/Python/comments/arxwkm/monte_carlo_simulation_with_python/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import seaborn as sns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "sns.set_style('whitegrid')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Define the variables for the Percent to target based on historical results\n",
    "avg = 1\n",
    "std_dev = .1\n",
    "num_reps = 500\n",
    "num_simulations = 100000"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Show an example of calculating the percent to target\n",
    "pct_to_target = np.random.normal(\n",
    "    avg,\n",
    "    std_dev,\n",
    "    size=(num_reps, num_simulations)\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.79328531, 0.99211018, 1.14343423, ..., 0.83737887, 0.93507967,\n",
       "        0.86079851],\n",
       "       [1.03126742, 1.04414961, 1.08119495, ..., 0.98607625, 1.01161899,\n",
       "        0.96872644],\n",
       "       [1.08616345, 0.93970666, 1.07594111, ..., 0.94057821, 1.00399945,\n",
       "        1.05325946],\n",
       "       ...,\n",
       "       [1.10388204, 0.90397305, 0.96005999, ..., 0.88810244, 1.18064642,\n",
       "        0.94066897],\n",
       "       [1.07581302, 0.92552317, 1.08256074, ..., 0.91934988, 1.06668758,\n",
       "        1.05969099],\n",
       "       [1.12755095, 0.95080038, 0.978849  , ..., 1.0094155 , 0.94359533,\n",
       "        1.06332923]])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pct_to_target[0:10]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Another example for the sales target distribution\n",
    "sales_target_values = [75_000, 100_000, 200_000, 300_000, 400_000, 500_000]\n",
    "sales_target_prob = [.3, .3, .2, .1, .05, .05]\n",
    "sales_target = np.random.choice(sales_target_values, p=sales_target_prob, \n",
    "                                size=(num_reps, num_simulations))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 75000, 200000,  75000, ...,  75000, 100000, 200000],\n",
       "       [200000,  75000, 100000, ..., 200000, 100000, 100000],\n",
       "       [400000,  75000, 100000, ..., 500000, 200000,  75000],\n",
       "       ...,\n",
       "       [500000,  75000, 500000, ...,  75000,  75000,  75000],\n",
       "       [ 75000, 100000,  75000, ...,  75000, 500000, 100000],\n",
       "       [100000,  75000,  75000, ..., 100000, 100000,  75000]])"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sales_target[0:10]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [],
   "source": [
    "commission_percentages = np.take(\n",
    "    np.array([0.04, 0.03, 0.02]),\n",
    "    np.digitize(pct_to_target, bins=[.9, .99, 10])\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2    26992625\n",
       "1    15075317\n",
       "0     7932058\n",
       "dtype: int64"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.DataFrame(np.digitize(pct_to_target, bins=[.9, .99, 10]).flatten()).value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.02    26992625\n",
       "0.03    15075317\n",
       "0.04     7932058\n",
       "dtype: int64"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# frequencies\n",
    "pd.DataFrame(commission_percentages.flatten()).value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.04, 0.02, 0.02, ..., 0.04, 0.03, 0.04],\n",
       "       [0.02, 0.02, 0.02, ..., 0.03, 0.02, 0.03],\n",
       "       [0.02, 0.03, 0.02, ..., 0.03, 0.02, 0.02],\n",
       "       ...,\n",
       "       [0.02, 0.03, 0.03, ..., 0.04, 0.02, 0.03],\n",
       "       [0.02, 0.03, 0.02, ..., 0.03, 0.02, 0.02],\n",
       "       [0.02, 0.03, 0.03, ..., 0.02, 0.03, 0.02]])"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "commission_percentages[0:10]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [],
   "source": [
    "total_commissions = (commission_percentages * sales_target).sum(axis=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "96546.42131435724"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "total_commissions.std()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Total_Commissions</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2838250.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2786750.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2795500.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3054750.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2831750.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Total_Commissions\n",
       "0          2838250.0\n",
       "1          2786750.0\n",
       "2          2795500.0\n",
       "3          3054750.0\n",
       "4          2831750.0"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Show how to create the dataframe\n",
    "df = pd.DataFrame(data={'Total_Commissions': total_commissions})\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:title={'center':'Commissions Distribution'}, ylabel='Frequency'>"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY0AAAERCAYAAACHA/vpAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAueElEQVR4nO3de1hU9aLG8e8wDEjMkJFlTyneMdONN7adEq9pWGreUUhKLdvaUbemblDxlve87LO1sDTr9GiCpGbu7OZtaxZ5klKLUIssRU3xspNBmUFY548OcyQVlikw6vt5np6HWfObtd65NK/rNstiGIaBiIiICT4VHUBERG4cKg0RETFNpSEiIqapNERExDSVhoiImKbSEBER01QaUq4KCgp488036dmzJ926dePxxx9n7ty5uN3ucs/SrVs3zp49e9WP27x5M9OnTy+DRMXVr1+frl270q1bN5544gl69uzJ22+/7bk/KSmJJUuWlDiPd955p9hjLnbx49u3b88333xzVfkOHz7M8OHDATh+/Dj9+vW7qsfLjcm3ogPIrWXKlCn8+uuvvPXWWzgcDs6dO8eYMWOYMGECc+fOLdcs77333h963COPPMIjjzxyndNc3ltvvUVwcDAAp0+fZsiQIbhcLgYNGkR0dHSpj09LS6NevXqXvc/M40ty9OhRDh48CEDVqlVJTk6+pvnJjcGik/ukvGRlZdGlSxd27NiB3W73TM/Ozuarr74iMjKSnJwcpk6dyr59+7BYLLRq1YoXXngBX19f/vSnPzFw4EA+//xzzp07x7Bhw/joo484cOAAd999N6+++iq33Xab6XH169cnNTWVgoIC4uLiOHPmDABt2rRh5MiRZGdnX3b62rVr+fjjj3nttdf45ZdfmDJlCkeOHMEwDLp3786zzz5LVlYWAwYMoE2bNuzZs4ezZ88yduxYOnbsSGZmJhMmTMDtdmMYBr179+bJJ5+85PUqyldUGgBfffUVI0aM4NNPP+Xll1/mzJkzTJo0iZUrV5KcnIzNZsPf358XX3yRgwcPMmHCBPz9/RkyZAinT59m9+7dnDhxgvr161OjRg3P49u3b8+DDz7Ivn37cLvdDBw4kN69e7Nz506mTZvG+++/D+C5/d5779GpUyeOHz/On//8Z6ZOnUrXrl35+uuvyc/PZ/bs2aSmpmK1WgkLC2PcuHHY7Xbat29Pjx49SE1N5dixY3Tr1o2RI0eW4adOrjdtnpJyk56eTt26dYsVBsBdd91FZGQkANOnT6dy5cr885//ZM2aNezfv5833ngDALfbTZUqVVi9ejXdu3cnISGBCRMm8MEHH+B0Otm8efNVjSuSkpJCtWrVePfdd3n77bf5+eefycnJueL0i40ZM4YHH3yQf/7znyQlJbF+/Xo2bNgA/Lb5JiIigtWrVzN69GhmzpwJwLJly2jfvj1r165lyZIl7Nq1i8LCQlOv4f333092dranyOC3TX4zZ87k9ddfZ82aNURFRZGWlkbHjh1p3749AwYM8JTSkSNHePfdd5k3b94l8/b39+fdd9/ljTfeYMGCBXz//fdXzGG1Wpk+fTohISEsW7as2H2LFy/mxIkTvPfee7z33nsUFhby0ksvee4/d+6cp+TeeOMNDh8+bOq5i3dQaUi58fHxKfXLcfv27fTv3x+LxYKfnx/9+vVj+/btnvuLyiUkJITQ0FCqVq2Kj48P1apV49dff73qcQCtWrXik08+YfDgwaxatYrRo0fjcDiuOL3IuXPn+OqrrzxfyA6Hg549e3ry2mw22rRpA8ADDzzAv//9bwA6duzI66+/zrBhw/jkk09ISEjAx8fc/4oWiwX47Qu+iNVqpVOnTvTr148XX3yRoKAgevfufdnHN2nSBF/fy2+VLtonUbVqVVq2bElqaqqpTL+3fft2+vXrh81mw8fHh9jYWD799FPP/UWb9qpWrcqdd955yfsh3k2lIeUmLCyMH3/8EafTWWz68ePHee6558jLy6OwsNDzxQhQWFjIhQsXPLdtNttl//49s+OKcm3evJm+ffty5MgR+vTpw7fffnvF6Rdn+/3W3YvzFn1pAsWeU7t27fj444957LHHyMjIoGvXrvzyyy8lZizyzTffUK1aNQIDA4tNnzdvHq+++iohISEsWbKEF1544bKPv+22264474uLq7CwEF9fXywWS7HnmJ+fX2rGy72HFz/u4sL7/fzF+6k0pNxUrVqVrl27Mn78eE9xOJ1OpkyZQuXKlalUqRIRERGsWLECwzBwu92kpKTw8MMPl2muefPmkZiYSIcOHZgwYQJ169bl+++/v+L0Ina7ncaNG3uOTsrJyWHdunWl5h09ejQffPABnTt3ZvLkydjtdg4dOlRqzuPHjzNv3jwGDRpUbPrp06dp06YNlStXZsCAAYwcOdJzJJTVai1WuiV59913gd92cKempvLQQw8RHBzM0aNHOXXqFIZheDa9Fc37ciXSqlUrkpKSyM/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KlJpr4W3vl7emMsbM8GNmaukMinTo6fmzJnDxx9/zMSJE4v95kpubi5BQUHY7XZyc3OLTXc4HMWmlzQ2KCioLOOLiMjvlElprFu3jtdeew347bKQFouFRo0asXPnTuC3C4qEh4cTFhZGWloaLpeLnJwcMjMzCQ0NpVmzZp7fkNm+fTvNmzfHbrdjs9k4dOgQhmGwY8cOwsPDyyK+iIhcQZlsnnr00UcZN24cTz75JBcuXGD8+PHUqVOHiRMnsmDBAmrXrk1kZCRWq5XY2FhiYmIwDINRo0bh7+9PdHQ0cXFxREdHY7PZmD9/PgBTp05lzJgxFBQUEBERQePGjcsivoiIXEGZlMZtt9122QugrFix4pJpUVFRREVFFZsWEBBwyWUdAZo0aUJKSsr1CyoiIldFZ4SLiIhpKg0RETFNpSEiIqapNERExDSVhoiImKbSEBER01QaIiJimkpDRERMU2mIiIhpKg0RETFNpSEiIqapNERExDSVhoiImKbSEBER01QaIiJimkpDRERMU2mIiIhpKg0RETFNpSEiIqapNERExDSVhoiImKbSEBER01QaIiJimkpDRERM873eM8zPz2f8+PEcOXIEt9vN0KFDueeeexgyZAg1a9YEIDo6mscff5yUlBSSk5Px9fVl6NChtGvXjry8PMaOHcupU6cIDAxkzpw5BAcHs3v3bmbMmIHVaiUiIoJhw4Zd7+giIlKK614a69evp3LlysydO5czZ87Qo0cP/vM//5OBAwcyaNAgz7js7GyWL1/OmjVrcLlcxMTE0LJlS5KSkggNDWX48OFs2LCBxMREEhISmDx5MosWLaJ69eo899xzpKen07Bhw+sdX0RESnDdS6NTp05ERkZ6blutVr799lsOHjzI5s2bqVGjBuPHj2fv3r00bdoUPz8//Pz8CAkJYd++faSlpfHss88C0Lp1axITE3E6nbjdbkJCQgCIiIggNTW11NJwuVxkZGRc76d4iby8vHJZztXyxlzelqlBgwYVuvzSXgtve72KeGMub8wEN1+u614agYGBADidTkaMGMHIkSNxu9306dOHRo0asXjxYl555RXuv/9+HA5Hscc5nU6cTqdnemBgIDk5OTidTux2e7Gxhw8fL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zTaUhInKTy8zMZOrUqcBv12+pVasWYWFhtGjRArvdjt1up06dOvz000+EhYWVOC+VhojITa5WrVrMmTOHe++9l7S0NLKzs6lVqxYrV67E5XJRUFDg+bn70qg0RERuclOmTCEuLo6CggIAZsyYQa1atejVqxfR0dEYhsHzzz/vuW5LSfTbUyIiYpqOnhIREdNUGiIiYppKQ0RETFNpiIiIaSoNERExTaUhIiKmqTRERMS0/wVf3ZYTm53/1wAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "df.plot(kind='hist', title='Commissions Distribution')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Total_Commissions</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>1.000000e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>2.831683e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>9.654690e+04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>2.472750e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>2.765750e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>2.830250e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>2.896500e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>3.278500e+06</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       Total_Commissions\n",
       "count       1.000000e+05\n",
       "mean        2.831683e+06\n",
       "std         9.654690e+04\n",
       "min         2.472750e+06\n",
       "25%         2.765750e+06\n",
       "50%         2.830250e+06\n",
       "75%         2.896500e+06\n",
       "max         3.278500e+06"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
